/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.CosBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.SoapProtocol;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.mailbox.RetentionPolicyManager;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.GetSystemRetentionPolicyRequest;
/*    */ import com.zimbra.soap.admin.message.GetSystemRetentionPolicyResponse;
/*    */ import com.zimbra.soap.admin.type.CosSelector;
/*    */ import com.zimbra.soap.admin.type.CosSelector.CosBy;
/*    */ import com.zimbra.soap.mail.type.RetentionPolicy;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetSystemRetentionPolicy
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 43 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 45 */     GetSystemRetentionPolicyRequest req = (GetSystemRetentionPolicyRequest)JaxbUtil.elementToJaxb(request);
/* 46 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 48 */     Entry entry = prov.getConfig();
/*    */     
/* 50 */     CosSelector cosSelector = req.getCos();
/* 51 */     if (cosSelector != null) {
/* 52 */       entry = prov.get(Key.CosBy.fromString(cosSelector.getBy().name()), cosSelector.getKey());
/* 53 */       if (entry == null) {
/* 54 */         throw AccountServiceException.NO_SUCH_COS(cosSelector.getKey());
/*    */       }
/*    */     }
/* 57 */     checkGetRight(entry, zsc, context);
/*    */     
/* 59 */     RetentionPolicy rp = RetentionPolicyManager.getInstance().getSystemRetentionPolicy(entry);
/* 60 */     GetSystemRetentionPolicyResponse res = new GetSystemRetentionPolicyResponse(rp);
/* 61 */     return JaxbUtil.jaxbToElement(res, zsc.getResponseProtocol().getFactory());
/*    */   }
/*    */   
/*    */   private void checkGetRight(Entry entry, ZimbraSoapContext zsc, Map<String, Object> context) throws ServiceException
/*    */   {
/* 66 */     AdminAccessControl.GetAttrsRight gar = new AdminAccessControl.GetAttrsRight();
/* 67 */     gar.addAttr("zimbraMailPurgeSystemPolicy");
/* 68 */     checkRight(zsc, context, entry, gar);
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 73 */     notes.add("Need get attr right on attribute zimbraMailPurgeSystemPolicy");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetSystemRetentionPolicy.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */